var Utils = (function () {
    utils = {};

    // 向量
    utils.vector = function (x1, x2) {
        return {
            x: x1.x - x2.x,
            y: x1.y - x2.y
        };
    };
    // 向量叉乘
    utils.vectorProduct = function (v1, v2) {
        return v1.x * v2.y - v2.x * v1.y;
    };
    // 判断是否在三角形内（A,B,C） M点 MA^MB MB^MC MC^MA
    utils.vectorOperation = function (a, b) {
        return (a ^ b) >= 0;
    };

    // 判断点是否在三角形内
    utils.vectorInTriangle = function (m, a, b, c) {

        var ma = this.vector(m, a);
        var mb = this.vector(m, b);
        var mc = this.vector(m, c);

        var o1 = this.vectorProduct(ma, mb);
        var o2 = this.vectorProduct(mb, mc);
        var o3 = this.vectorProduct(mc, ma);

        var reslut = this.vectorOperation(o1, o2) && this.vectorOperation(o2, o3);

        ma = mb = mc = o1 = o2 = o3 = null;

        return reslut;
    };
    


    return utils;
})();